// pages/mine/mine.js
  Page({
    data: {
      isHidden: false, // 控制弹窗显示
      avatarUrl: '', // 用户头像 URL
      nickName: '' ,// 用户昵称
      userInfo: null, // 用户信息
      hasUserInfo: false // 是否已获取用户信息
    },
    onShow(){
      let userInfo=wx.getStorageSync('userInfo')
      this.setData({
        avatarUrl:userInfo.avatarUrl,
        nickName:userInfo.nickName
      })
    },
    go(){
      let userInfo=wx.getStorageSync('userInfo')
      this.setData({
        avatarUrl:userInfo.avatarUrl,
        nickName:userInfo.nickName
      })
    },
  onNavigateToPersonalInfo: function() {
    wx.navigateTo({
      url: '/pages/mine/personal-info/personal-info'
    });
  },
  onNavigateToFavorites: function() {
    console.log('Navigate to Favorites');
    wx.navigateTo({
      url: '/pages/mine/favorites/favorites'
    });
  },
  
  onNavigateToCollections: function() {
    console.log('Navigate to Collections');
    wx.navigateTo({
      url: '/pages/mine/collections/collections'
    });
  },
  
  onNavigateToRecords: function() {
    console.log('Navigate to Records');
    wx.navigateTo({
      url: '/pages/mine/records/records'
    });
  },
  
  onNavigateToFeedback: function() {
    console.log('Navigate to Feedback');
    wx.navigateTo({
      url: '/pages/mine/feedback/feedback'
    });
  },
  onNavigateToModifyPassword() {
   
    wx.navigateTo({
      url: '/pages/mine/modifyPassword/index'
    });
    console.log('Navigate to Modify Password');
  },
  onNavigateToAboutUs: function() {
    console.log('Navigate to About Us');
    wx.navigateTo({
      url: '/pages/mine/about-us/index'
    });
  },
  onNavigateToLogout: function() {
    wx.showModal({
      title: '退出登录',
      content: '确定要退出登录吗？',
      success: (res) => {
          if (res.confirm) {
              // 清除本地存储
              wx.clearStorageSync();

              // 重新跳转到登录页面
              wx.reLaunch({
                  url: '/pages/login/login'
              });

              // 更新页面数据
              this.setData({
                  nickName: '',
                  avatarUrl: ''
              });
          }
      }
  });
  },
 // 取消登录
 cancelLogin: function() {
  this.setData({ 
    isHidden:true, 
    avatarUrl:'../../mineImage/headPicture.png'
  });
},
});
